<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function getSum(num1, num2) {
            return num1 + num2;
        }
        console.log(getSum(3, 100));

        function cook(aru) {
            return aru;
        }
        console.log(cook('大肘子，糖醋里脊'));

        // 案例1、利用函数返回值求任意两个数的最大值
        function getMax(num1, num2) {
            // if (num1 > num2) {
            //     return num1;
            // } else {
            //     return num2;
            // }
            return num1 > num2 ? num1 : num2;
        }
        console.log(getMax(10, 100));

        // 案例2、利用函数返回值求任意一个数组中的最大值
        function getArrMax(arr) {
            var max = arr[0];
            for (var i = 1; i <= arr.length; i++) {
                if (arr[i] > max) {
                    max = arr[i];
                }
            }
            return max;
        }
        var re = getArrMax([5, 2, 99, 78, 85, 4, 7, 33])
        console.log(re);
    </script>
</body>

</html>